/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * vistaProveedor.java
 *
 * Created on 21-dic-2011, 10:05:12
 */
package invsys.Vistas;

import invsys.Controladores.ContactoControl;
import invsys.Controladores.ControlProducto;
import invsys.Controladores.ControlProveedor;
import invsys.Modelo.Contacto;
import invsys.Modelo.Producto;
import invsys.Modelo.Proveedor;
import invsys.Utilidades.ManejadorBaseDatos;
import invsys.Utilidades.ValidarorVistas;
import java.io.IOException;
import java.sql.SQLException;
import java.util.Iterator;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author luigie
 */
public class vistaProveedor extends javax.swing.JDialog {
 ValidarorVistas vistas = new ValidarorVistas();
 DefaultComboBoxModel cbprov = new DefaultComboBoxModel();
 DefaultTableModel dtm = new DefaultTableModel();
 DefaultTableModel dtm2 = new DefaultTableModel();
 String i;
 boolean val;
    /** Creates new form vistaProveedor */
    public vistaProveedor() {
         initComponents();
        this.setLocationRelativeTo(null);
        listarProveedor();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        RegistroContacto = new javax.swing.JDialog();
        jPanel14 = new invsys.Imagenes.Fondo.panel("negocios.jpg");
        jPanel15 = new invsys.Imagenes.Fondo.panel("transparente.png");
        btnRegistroContacto = new javax.swing.JButton();
        limpiar = new javax.swing.JButton();
        btnsalirnuevocont = new javax.swing.JButton();
        jPanel13 = new invsys.Imagenes.Fondo.panel("transparente.png");
        jLabel16 = new javax.swing.JLabel();
        nombre = new javax.swing.JLabel();
        jLabel18 = new javax.swing.JLabel();
        nit = new javax.swing.JLabel();
        jPanel12 = new invsys.Imagenes.Fondo.panel("transparente.png");
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        txtNombreContacto = new javax.swing.JTextField();
        txtIdContacto = new javax.swing.JTextField();
        txtApellidoContacto = new javax.swing.JTextField();
        txtDireccionContacto = new javax.swing.JTextField();
        txtTelefonoContacto = new javax.swing.JTextField();
        txtCelullarContacto = new javax.swing.JTextField();
        mensaje2 = new javax.swing.JLabel();
        jPanel1 = new invsys.Imagenes.Fondo.panel("fondo1.jpg");
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel2 = new invsys.Imagenes.Fondo.panel("negocios.jpg");
        jPanel4 = new invsys.Imagenes.Fondo.panel("transparente.png");
        jLabel1 = new javax.swing.JLabel();
        txtNit = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        txtNombre = new javax.swing.JTextField();
        txtDireccion = new javax.swing.JTextField();
        txtTelefono = new javax.swing.JTextField();
        jPanel5 = new invsys.Imagenes.Fondo.panel("transparente.png");
        btn_RegistrarProve = new javax.swing.JButton();
        btn_LimpiarProve = new javax.swing.JButton();
        jPanel3 = new invsys.Imagenes.Fondo.panel("negocios.jpg");
        jTabbedPane2 = new javax.swing.JTabbedPane();
        jPanel8 = new invsys.Imagenes.Fondo.panel("fondo.jpg");
        jPanel6 = new invsys.Imagenes.Fondo.panel("transparente.png");
        jLabel6 = new javax.swing.JLabel();
        txtEdiartNit = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        txtEditarDireccion = new javax.swing.JTextField();
        txtEditarNombre = new javax.swing.JTextField();
        txtEditarTelefono = new javax.swing.JTextField();
        jPanel9 = new invsys.Imagenes.Fondo.panel("transparente.png");
        btn_EditarProveedor = new javax.swing.JButton();
        jPanel10 = new invsys.Imagenes.Fondo.panel("fondo.jpg");
        jPanel7 = new invsys.Imagenes.Fondo.panel("transparente.png");
        jScrollPane1 = new javax.swing.JScrollPane();
        jXTable1 = new org.jdesktop.swingx.JXTable(dtm);
        jPanel11 = new invsys.Imagenes.Fondo.panel("transparente.png");
        btn_EditarContactos = new javax.swing.JButton();
        btn_Agregar = new javax.swing.JButton();
        jPanel16 = new invsys.Imagenes.Fondo.panel("fondo.jpg");
        jPanel17 = new invsys.Imagenes.Fondo.panel("transparente.png");
        jScrollPane2 = new javax.swing.JScrollPane();
        jXTable2 = new org.jdesktop.swingx.JXTable(dtm2);
        jPanel18 = new invsys.Imagenes.Fondo.panel("transparente.png");
        btn_EditarContactos1 = new javax.swing.JButton();
        btn_Agregar1 = new javax.swing.JButton();
        jLabel5 = new javax.swing.JLabel();
        listaproveedor = new javax.swing.JComboBox();
        btn_salir = new javax.swing.JButton();
        mensaje = new javax.swing.JLabel();
        btnsalirnuevocont1 = new javax.swing.JButton();

        RegistroContacto.setMinimumSize(new java.awt.Dimension(450, 450));
        RegistroContacto.setModal(true);

        jPanel14.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Contacto", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Berlin Sans FB", 1, 12))); // NOI18N

        btnRegistroContacto.setIcon(new javax.swing.ImageIcon(getClass().getResource("/invsys/Imagenes/Botones/agregar.png"))); // NOI18N
        btnRegistroContacto.setText("Registrar");
        btnRegistroContacto.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/invsys/Imagenes/Botones/cancel.png"))); // NOI18N
        btnRegistroContacto.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/invsys/Imagenes/Botones/agregar1.png"))); // NOI18N
        btnRegistroContacto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnRegistroContactoActionPerformed(evt);
            }
        });

        limpiar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/invsys/Imagenes/Botones/1327507759_edit-clear.png"))); // NOI18N
        limpiar.setText("Limpiar");
        limpiar.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/invsys/Imagenes/Botones/1327507765_edit-clear.png"))); // NOI18N
        limpiar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                limpiarActionPerformed(evt);
            }
        });

        btnsalirnuevocont.setIcon(new javax.swing.ImageIcon(getClass().getResource("/invsys/Imagenes/Botones/Salir.png"))); // NOI18N
        btnsalirnuevocont.setText("Salir");
        btnsalirnuevocont.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/invsys/Imagenes/Botones/Sali1.png"))); // NOI18N
        btnsalirnuevocont.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnsalirnuevocontActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel15Layout = new javax.swing.GroupLayout(jPanel15);
        jPanel15.setLayout(jPanel15Layout);
        jPanel15Layout.setHorizontalGroup(
            jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel15Layout.createSequentialGroup()
                .addGap(18, 18, 18)
                .addComponent(btnRegistroContacto)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(limpiar)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnsalirnuevocont, javax.swing.GroupLayout.PREFERRED_SIZE, 118, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(27, Short.MAX_VALUE))
        );
        jPanel15Layout.setVerticalGroup(
            jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel15Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnsalirnuevocont, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(limpiar)
                    .addComponent(btnRegistroContacto))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel13.setBorder(javax.swing.BorderFactory.createTitledBorder("Datos del Proveedor"));

        jLabel16.setText("Contacto de:");

        jLabel18.setText("Nit:");

        javax.swing.GroupLayout jPanel13Layout = new javax.swing.GroupLayout(jPanel13);
        jPanel13.setLayout(jPanel13Layout);
        jPanel13Layout.setHorizontalGroup(
            jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel13Layout.createSequentialGroup()
                .addGap(18, 18, 18)
                .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel16)
                    .addComponent(jLabel18))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(nombre, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(nit, javax.swing.GroupLayout.DEFAULT_SIZE, 227, Short.MAX_VALUE))
                .addContainerGap(27, Short.MAX_VALUE))
        );
        jPanel13Layout.setVerticalGroup(
            jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel13Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel16)
                    .addComponent(nombre, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(nit, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel18))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel12.setBorder(javax.swing.BorderFactory.createTitledBorder("Datos del Contacto"));

        jLabel10.setText("Id:");

        jLabel11.setText("Nombre:");

        jLabel12.setText("Apellido:");

        jLabel13.setText("Dirección:");

        jLabel14.setText("Telefono:");

        jLabel15.setText("Celular:");

        txtNombreContacto.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                txtNombreContactoFocusGained(evt);
            }
        });

        txtIdContacto.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                txtIdContactoFocusGained(evt);
            }
        });
        txtIdContacto.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                txtIdContactoKeyReleased(evt);
            }
        });

        txtApellidoContacto.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                txtApellidoContactoFocusGained(evt);
            }
        });

        txtTelefonoContacto.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                txtTelefonoContactoKeyReleased(evt);
            }
        });

        txtCelullarContacto.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                txtCelullarContactoKeyReleased(evt);
            }
        });

        mensaje2.setFont(new java.awt.Font("Tahoma", 0, 12));
        mensaje2.setForeground(new java.awt.Color(255, 0, 0));
        mensaje2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);

        javax.swing.GroupLayout jPanel12Layout = new javax.swing.GroupLayout(jPanel12);
        jPanel12.setLayout(jPanel12Layout);
        jPanel12Layout.setHorizontalGroup(
            jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel12Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel12Layout.createSequentialGroup()
                        .addComponent(jLabel15)
                        .addGap(18, 18, 18)
                        .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel12Layout.createSequentialGroup()
                                .addGap(10, 10, 10)
                                .addComponent(mensaje2, javax.swing.GroupLayout.DEFAULT_SIZE, 231, Short.MAX_VALUE))
                            .addComponent(txtCelullarContacto, javax.swing.GroupLayout.PREFERRED_SIZE, 240, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addGroup(jPanel12Layout.createSequentialGroup()
                            .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabel13)
                                .addComponent(jLabel14))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                            .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(txtTelefonoContacto, javax.swing.GroupLayout.DEFAULT_SIZE, 238, Short.MAX_VALUE)
                                .addComponent(txtDireccionContacto)))
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel12Layout.createSequentialGroup()
                                .addComponent(jLabel12)
                                .addGap(18, 18, 18)
                                .addComponent(txtApellidoContacto))
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel12Layout.createSequentialGroup()
                                .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel11)
                                    .addComponent(jLabel10))
                                .addGap(18, 18, 18)
                                .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(txtIdContacto, javax.swing.GroupLayout.DEFAULT_SIZE, 236, Short.MAX_VALUE)
                                    .addComponent(txtNombreContacto))))))
                .addGap(39, 39, 39))
        );
        jPanel12Layout.setVerticalGroup(
            jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel12Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel10)
                    .addComponent(txtIdContacto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel11)
                    .addComponent(txtNombreContacto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel12)
                    .addComponent(txtApellidoContacto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel13)
                    .addComponent(txtDireccionContacto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(12, 12, 12)
                .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel14)
                    .addComponent(txtTelefonoContacto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel15)
                    .addComponent(txtCelullarContacto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(mensaje2, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel14Layout = new javax.swing.GroupLayout(jPanel14);
        jPanel14.setLayout(jPanel14Layout);
        jPanel14Layout.setHorizontalGroup(
            jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel14Layout.createSequentialGroup()
                .addGroup(jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel14Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jPanel13, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel14Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(jPanel15, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jPanel12, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
                .addContainerGap())
        );
        jPanel14Layout.setVerticalGroup(
            jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel14Layout.createSequentialGroup()
                .addComponent(jPanel13, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel12, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel15, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(24, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout RegistroContactoLayout = new javax.swing.GroupLayout(RegistroContacto.getContentPane());
        RegistroContacto.getContentPane().setLayout(RegistroContactoLayout);
        RegistroContactoLayout.setHorizontalGroup(
            RegistroContactoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel14, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        RegistroContactoLayout.setVerticalGroup(
            RegistroContactoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel14, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Registrar Provedor", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Berlin Sans FB Demi", 1, 14))); // NOI18N

        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Datos Proveedor", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION));

        jLabel1.setText("Nit:");

        txtNit.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                txtNitFocusGained(evt);
            }
        });

        jLabel2.setText("Nombre:");

        jLabel3.setText("Dirección:");

        jLabel4.setText("Telefono:");

        txtNombre.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                txtNombreFocusGained(evt);
            }
        });

        txtTelefono.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                txtTelefonoKeyPressed(evt);
            }
            public void keyReleased(java.awt.event.KeyEvent evt) {
                txtTelefonoKeyReleased(evt);
            }
        });

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                .addGap(31, 31, 31)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel3)
                            .addComponent(jLabel1))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(txtDireccion, javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txtNit, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 217, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanel4Layout.createSequentialGroup()
                            .addComponent(jLabel2)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                            .addComponent(txtNombre, javax.swing.GroupLayout.DEFAULT_SIZE, 217, Short.MAX_VALUE))
                        .addGroup(jPanel4Layout.createSequentialGroup()
                            .addComponent(jLabel4)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(txtTelefono, javax.swing.GroupLayout.DEFAULT_SIZE, 218, Short.MAX_VALUE))))
                .addGap(29, 29, 29))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(txtNit, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(txtDireccion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(txtNombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(txtTelefono, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Opciones", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION));

        btn_RegistrarProve.setIcon(new javax.swing.ImageIcon(getClass().getResource("/invsys/Imagenes/Botones/agregar.png"))); // NOI18N
        btn_RegistrarProve.setText("Registrar");
        btn_RegistrarProve.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/invsys/Imagenes/Botones/agregar1.png"))); // NOI18N
        btn_RegistrarProve.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_RegistrarProveActionPerformed(evt);
            }
        });

        btn_LimpiarProve.setIcon(new javax.swing.ImageIcon(getClass().getResource("/invsys/Imagenes/Botones/1327507759_edit-clear.png"))); // NOI18N
        btn_LimpiarProve.setText("Limpiar");
        btn_LimpiarProve.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/invsys/Imagenes/Botones/1327507765_edit-clear.png"))); // NOI18N
        btn_LimpiarProve.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_LimpiarProveActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
                .addGap(19, 19, 19)
                .addComponent(btn_RegistrarProve, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 46, Short.MAX_VALUE)
                .addComponent(btn_LimpiarProve, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(32, 32, 32))
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btn_RegistrarProve, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btn_LimpiarProve, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(21, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(36, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Preveedor", jPanel2);

        jPanel6.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Datos Proveedor", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION));

        jLabel6.setText("Nit:");

        txtEdiartNit.setEditable(false);
        txtEdiartNit.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                txtEdiartNitFocusGained(evt);
            }
        });

        jLabel7.setText("Dirección:");

        jLabel8.setText("Nombre:");

        jLabel9.setText("Telefono:");

        txtEditarDireccion.setEditable(false);

        txtEditarNombre.setEditable(false);
        txtEditarNombre.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                txtEditarNombreFocusGained(evt);
            }
        });

        txtEditarTelefono.setEditable(false);
        txtEditarTelefono.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                txtEditarTelefonoKeyReleased(evt);
            }
        });

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel8, javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel6Layout.createSequentialGroup()
                        .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel7)
                            .addComponent(jLabel9))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txtEditarTelefono, javax.swing.GroupLayout.DEFAULT_SIZE, 196, Short.MAX_VALUE)
                            .addComponent(txtEditarNombre, javax.swing.GroupLayout.DEFAULT_SIZE, 196, Short.MAX_VALUE)
                            .addComponent(txtEditarDireccion, javax.swing.GroupLayout.DEFAULT_SIZE, 196, Short.MAX_VALUE)))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel6Layout.createSequentialGroup()
                        .addComponent(jLabel6)
                        .addGap(33, 33, 33)
                        .addComponent(txtEdiartNit, javax.swing.GroupLayout.PREFERRED_SIZE, 197, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(57, 57, 57))
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(txtEdiartNit, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(txtEditarDireccion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8)
                    .addComponent(txtEditarNombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9)
                    .addComponent(txtEditarTelefono, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel9.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION));

        btn_EditarProveedor.setIcon(new javax.swing.ImageIcon(getClass().getResource("/invsys/Imagenes/Botones/editar.png"))); // NOI18N
        btn_EditarProveedor.setText("Editar");
        btn_EditarProveedor.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/invsys/Imagenes/Botones/cancel.png"))); // NOI18N
        btn_EditarProveedor.setEnabled(false);
        btn_EditarProveedor.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/invsys/Imagenes/Botones/editar1.png"))); // NOI18N
        btn_EditarProveedor.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_EditarProveedorActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel9Layout = new javax.swing.GroupLayout(jPanel9);
        jPanel9.setLayout(jPanel9Layout);
        jPanel9Layout.setHorizontalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel9Layout.createSequentialGroup()
                .addContainerGap(50, Short.MAX_VALUE)
                .addComponent(btn_EditarProveedor, javax.swing.GroupLayout.PREFERRED_SIZE, 127, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(41, 41, 41))
        );
        jPanel9Layout.setVerticalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel9Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(btn_EditarProveedor, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8);
        jPanel8.setLayout(jPanel8Layout);
        jPanel8Layout.setHorizontalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel8Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(jPanel8Layout.createSequentialGroup()
                        .addGap(68, 68, 68)
                        .addComponent(jPanel9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        jPanel8Layout.setVerticalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        jTabbedPane2.addTab("Datos", jPanel8);

        jPanel7.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Contactos", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION));

        dtm.addColumn("Id");
        dtm.addColumn("Nombre y Apellido");
        dtm.addColumn("Dirección");
        dtm.addColumn("Telefono");
        dtm.addColumn("Celular");
        jXTable1.setColumnControlVisible(true);
        jXTable1.setEditable(false);
        jXTable1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jXTable1MouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(jXTable1);

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 314, Short.MAX_VALUE)
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel11.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION));

        btn_EditarContactos.setIcon(new javax.swing.ImageIcon(getClass().getResource("/invsys/Imagenes/Botones/editar.png"))); // NOI18N
        btn_EditarContactos.setText("Editar");
        btn_EditarContactos.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/invsys/Imagenes/Botones/cancel.png"))); // NOI18N
        btn_EditarContactos.setEnabled(false);
        btn_EditarContactos.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/invsys/Imagenes/Botones/editar1.png"))); // NOI18N
        btn_EditarContactos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_EditarContactosActionPerformed(evt);
            }
        });

        btn_Agregar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/invsys/Imagenes/Botones/agregar.png"))); // NOI18N
        btn_Agregar.setText("Agregar");
        btn_Agregar.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/invsys/Imagenes/Botones/cancel.png"))); // NOI18N
        btn_Agregar.setEnabled(false);
        btn_Agregar.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/invsys/Imagenes/Botones/agregar1.png"))); // NOI18N
        btn_Agregar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_AgregarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel11Layout = new javax.swing.GroupLayout(jPanel11);
        jPanel11.setLayout(jPanel11Layout);
        jPanel11Layout.setHorizontalGroup(
            jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel11Layout.createSequentialGroup()
                .addGap(21, 21, 21)
                .addComponent(btn_Agregar, javax.swing.GroupLayout.PREFERRED_SIZE, 133, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(btn_EditarContactos, javax.swing.GroupLayout.DEFAULT_SIZE, 140, Short.MAX_VALUE)
                .addGap(18, 18, 18))
        );
        jPanel11Layout.setVerticalGroup(
            jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel11Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btn_Agregar, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btn_EditarContactos, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        javax.swing.GroupLayout jPanel10Layout = new javax.swing.GroupLayout(jPanel10);
        jPanel10.setLayout(jPanel10Layout);
        jPanel10Layout.setHorizontalGroup(
            jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel10Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel11, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
            .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel10Layout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(jPanel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addContainerGap()))
        );
        jPanel10Layout.setVerticalGroup(
            jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel10Layout.createSequentialGroup()
                .addGap(138, 138, 138)
                .addComponent(jPanel11, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
            .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel10Layout.createSequentialGroup()
                    .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(70, Short.MAX_VALUE)))
        );

        jTabbedPane2.addTab("Contactos", jPanel10);

        jPanel17.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Productos", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION));

        dtm2.addColumn("Id");
        dtm2.addColumn("Nombre");
        dtm2.addColumn("Descripcion");
        dtm2.addColumn("Cantidad");
        jXTable2.setColumnControlVisible(true);
        jXTable2.setEditable(false);
        jXTable2.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jXTable2MouseClicked(evt);
            }
        });
        jScrollPane2.setViewportView(jXTable2);

        javax.swing.GroupLayout jPanel17Layout = new javax.swing.GroupLayout(jPanel17);
        jPanel17.setLayout(jPanel17Layout);
        jPanel17Layout.setHorizontalGroup(
            jPanel17Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 314, Short.MAX_VALUE)
        );
        jPanel17Layout.setVerticalGroup(
            jPanel17Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel17Layout.createSequentialGroup()
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel18.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION));

        btn_EditarContactos1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/invsys/Imagenes/Botones/editar.png"))); // NOI18N
        btn_EditarContactos1.setText("Editar");
        btn_EditarContactos1.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/invsys/Imagenes/Botones/cancel.png"))); // NOI18N
        btn_EditarContactos1.setEnabled(false);
        btn_EditarContactos1.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/invsys/Imagenes/Botones/editar1.png"))); // NOI18N
        btn_EditarContactos1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_EditarContactos1ActionPerformed(evt);
            }
        });

        btn_Agregar1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/invsys/Imagenes/Botones/agregar.png"))); // NOI18N
        btn_Agregar1.setText("Agregar");
        btn_Agregar1.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/invsys/Imagenes/Botones/cancel.png"))); // NOI18N
        btn_Agregar1.setEnabled(false);
        btn_Agregar1.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/invsys/Imagenes/Botones/agregar1.png"))); // NOI18N
        btn_Agregar1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_Agregar1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel18Layout = new javax.swing.GroupLayout(jPanel18);
        jPanel18.setLayout(jPanel18Layout);
        jPanel18Layout.setHorizontalGroup(
            jPanel18Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel18Layout.createSequentialGroup()
                .addGap(21, 21, 21)
                .addComponent(btn_Agregar1, javax.swing.GroupLayout.PREFERRED_SIZE, 133, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(btn_EditarContactos1, javax.swing.GroupLayout.DEFAULT_SIZE, 140, Short.MAX_VALUE)
                .addGap(18, 18, 18))
        );
        jPanel18Layout.setVerticalGroup(
            jPanel18Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel18Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel18Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btn_Agregar1, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btn_EditarContactos1, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        javax.swing.GroupLayout jPanel16Layout = new javax.swing.GroupLayout(jPanel16);
        jPanel16.setLayout(jPanel16Layout);
        jPanel16Layout.setHorizontalGroup(
            jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel16Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel17, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel18, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel16Layout.setVerticalGroup(
            jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel16Layout.createSequentialGroup()
                .addComponent(jPanel17, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel18, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(10, 10, 10))
        );

        jTabbedPane2.addTab("Productos", jPanel16);

        jLabel5.setText("Elegir Proveedor:");

        listaproveedor.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                listaproveedorActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(jLabel5)
                        .addGap(18, 18, 18)
                        .addComponent(listaproveedor, javax.swing.GroupLayout.PREFERRED_SIZE, 190, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(70, 70, 70))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(jTabbedPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 351, Short.MAX_VALUE)
                        .addContainerGap())))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(listaproveedor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel5))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTabbedPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 231, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(12, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Gestion Proveedor", jPanel3);

        btn_salir.setText("Salir");
        btn_salir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_salirActionPerformed(evt);
            }
        });

        mensaje.setFont(new java.awt.Font("Tahoma", 0, 12));
        mensaje.setForeground(new java.awt.Color(255, 0, 0));
        mensaje.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);

        btnsalirnuevocont1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/invsys/Imagenes/Botones/Salir.png"))); // NOI18N
        btnsalirnuevocont1.setText("Salir");
        btnsalirnuevocont1.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/invsys/Imagenes/Botones/Sali1.png"))); // NOI18N
        btnsalirnuevocont1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnsalirnuevocont1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addGroup(jPanel1Layout.createSequentialGroup()
                            .addComponent(mensaje, javax.swing.GroupLayout.PREFERRED_SIZE, 220, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(380, 380, 380))
                        .addGroup(jPanel1Layout.createSequentialGroup()
                            .addGap(249, 249, 249)
                            .addComponent(btnsalirnuevocont1, javax.swing.GroupLayout.PREFERRED_SIZE, 118, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(btn_salir, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 376, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(30, 30, 30)
                        .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 308, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(mensaje)
                                .addGap(25, 25, 25))
                            .addComponent(btnsalirnuevocont1, javax.swing.GroupLayout.DEFAULT_SIZE, 25, Short.MAX_VALUE)))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addGap(340, 340, 340)
                        .addComponent(btn_salir, javax.swing.GroupLayout.DEFAULT_SIZE, 29, Short.MAX_VALUE)))
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 406, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btn_RegistrarProveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_RegistrarProveActionPerformed
        // TODO add your handling code here:
        
        if(vistas.CamposVacios(txtNit,txtNombre)){
            try {
                Proveedor p = ControlProveedor.BuscarProveedor(txtNit.getText());
                if(p == null){
                p = new Proveedor();
                p.setNit(txtNit.getText());
                p.setDireccion(txtDireccion.getText());
                p.setNombre(txtNombre.getText());
                p.setTelefono(txtTelefono.getText());
                ControlProveedor.RegistrarProveedor(p);
                nombre.setText(txtNombre.getText());
                nit.setText(txtNit.getText());
                btnRegistroContacto.setText("Registrar");
                RegistroContacto.setLocationRelativeTo(this);
                RegistroContacto.setVisible(true);
                vistas.VaciarCampos(txtNit,txtDireccion,txtNombre,txtTelefono);
                listarProveedor();
                
                }else
                    mensaje.setText("Proveedor ya Existe..");
            } catch (IOException ex) {
                Logger.getLogger(vistaProveedor.class.getName()).log(Level.SEVERE, null, ex);
            } catch (SQLException ex) {
                Logger.getLogger(vistaProveedor.class.getName()).log(Level.SEVERE, null, ex);
            } catch (Exception ex) {
                Logger.getLogger(vistaProveedor.class.getName()).log(Level.SEVERE, null, ex);
            }
            
            
        }else
            mensaje.setText("Campo vacio");
            
    }//GEN-LAST:event_btn_RegistrarProveActionPerformed

    private void txtNitFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtNitFocusGained
        vistas.RetornaColor(txtNit);
        mensaje.setText("");
    }//GEN-LAST:event_txtNitFocusGained

    private void txtNombreFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtNombreFocusGained
        vistas.RetornaColor(txtNombre);
        mensaje.setText("");
    }//GEN-LAST:event_txtNombreFocusGained

    private void btn_LimpiarProveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_LimpiarProveActionPerformed
       vistas.VaciarCampos(txtNit,txtDireccion,txtNombre,txtTelefono);
       vistas.VaciarCampos(mensaje);
       vistas.RetornaColor(txtNit,txtNombre);
    }//GEN-LAST:event_btn_LimpiarProveActionPerformed

    private void txtTelefonoKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtTelefonoKeyPressed
    
    }//GEN-LAST:event_txtTelefonoKeyPressed

    private void txtTelefonoKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtTelefonoKeyReleased
     
        vistas.validarnumero(txtTelefono, mensaje);
       
    }//GEN-LAST:event_txtTelefonoKeyReleased

    private void btn_salirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_salirActionPerformed
       
        this.setVisible(false);
        
    }//GEN-LAST:event_btn_salirActionPerformed

    private void listaproveedorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_listaproveedorActionPerformed
        if(listaproveedor.getSelectedIndex() != 0){
        try {
            Proveedor p2 = ControlProveedor.BuscarProveedornombre(listaproveedor.getSelectedItem().toString());
            txtEdiartNit.setText(p2.getNit());
            txtEditarDireccion.setText(p2.getDireccion());
            txtEditarNombre.setText(p2.getNombre());
            txtEditarTelefono.setText(p2.getTelefono());
            btn_EditarProveedor.setEnabled(true);
            btn_Agregar.setEnabled(true);
            btn_EditarContactos.setEnabled(false);
            btn_EditarProveedor.setEnabled(true);
            ListarContactos(listaproveedor.getSelectedItem().toString());
            listaProductos(listaproveedor.getSelectedItem().toString());
            vistas.VaciarCampos(mensaje);
        } catch (SQLException ex) {
            Logger.getLogger(vistaProveedor.class.getName()).log(Level.SEVERE, null, ex);
        }catch(NullPointerException npe){
           
        }
        }else{
            vistas.VaciarCampos(txtEdiartNit, txtEditarDireccion, txtEditarNombre, txtEditarTelefono);
            ListarContactos(listaproveedor.getSelectedItem().toString());
            btn_Agregar.setEnabled(false);
            btn_EditarContactos.setEnabled(false);
            btn_EditarProveedor.setEnabled(false);
            vistas.VaciarCampos(mensaje);
        }
    }//GEN-LAST:event_listaproveedorActionPerformed

    private void btn_EditarProveedorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_EditarProveedorActionPerformed
        if(btn_EditarProveedor.getText().equals("Editar")){
                txtEdiartNit.setEditable(true);
                txtEditarDireccion.setEditable(true);
                txtEditarNombre.setEditable(true);
                txtEditarTelefono.setEditable(true);
                btn_EditarProveedor.setText("Guardar");
 
        }else{
             if(vistas.CamposVacios(txtEdiartNit, txtEditarNombre)){
                try {
                    Proveedor p3 = ControlProveedor.BuscarProveedornombre(listaproveedor.getSelectedItem().toString());
                    Proveedor p4 = new Proveedor();
                    p4.setNit(txtEdiartNit.getText());
                    p4.setDireccion(txtEditarDireccion.getText());
                    p4.setNombre(txtEditarNombre.getText());
                    p4.setTelefono(txtEditarTelefono.getText());
                    ControlProveedor.ModificarProveedor(p4, p3.getNit());
                    txtEdiartNit.setEditable(false);
                    txtEditarDireccion.setEditable(false);
                    txtEditarNombre.setEditable(false);
                    txtEditarTelefono.setEditable(false);
                    btn_EditarProveedor.setText("Editar");
                    btn_EditarProveedor.setEnabled(false);
                    listarProveedor();
                    JOptionPane.showMessageDialog(this,"La Modificacion a Sido Exitosa");
                } catch (SQLException ex) {
                    Logger.getLogger(vistaProveedor.class.getName()).log(Level.SEVERE, null, ex);
                } catch (Exception ex) {
                    Logger.getLogger(vistaProveedor.class.getName()).log(Level.SEVERE, null, ex);
                }
             }else
                 mensaje.setText("Campo vacio");
             
        }
    }//GEN-LAST:event_btn_EditarProveedorActionPerformed

    private void txtEdiartNitFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtEdiartNitFocusGained
        vistas.RetornaColor(txtEdiartNit);
        vistas.VaciarCampos(mensaje);
        
        
    }//GEN-LAST:event_txtEdiartNitFocusGained

    private void txtEditarNombreFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtEditarNombreFocusGained
        vistas.RetornaColor(txtEditarNombre);
        vistas.VaciarCampos(mensaje);
             
    }//GEN-LAST:event_txtEditarNombreFocusGained

    private void btnsalirnuevocontActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnsalirnuevocontActionPerformed
       RegistroContacto.setVisible(false);
        
    }//GEN-LAST:event_btnsalirnuevocontActionPerformed

    private void btnRegistroContactoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRegistroContactoActionPerformed
     if(vistas.CamposVacios(txtIdContacto, txtNombreContacto, txtApellidoContacto)){
          
                Contacto c;
         if(btnRegistroContacto.getText().equals("Guardar")) {
                try {
                    Contacto c2 = new Contacto();
                    c = ContactoControl.BuscarContacto(i);
                     c2.setId(txtIdContacto.getText());
                     c2.setNombre(txtNombreContacto.getText());
                     c2.setApellido(txtApellidoContacto.getText());
                     c2.setDireccion(txtDireccionContacto.getText());
                     c2.setTelefono(txtTelefonoContacto.getText());
                     c2.setCelular(txtCelullarContacto.getText());
                     ContactoControl. ModificarContacto(c2, c.getId());
                     ListarContactos(listaproveedor.getSelectedItem().toString());
                     vistas.VaciarCampos(txtIdContacto, txtNombreContacto, txtApellidoContacto, txtDireccionContacto, txtTelefonoContacto, txtCelullarContacto);
                     RegistroContacto.setVisible(false);
                  
                    
                } catch (SQLException ex) {
                    Logger.getLogger(vistaProveedor.class.getName()).log(Level.SEVERE, null, ex);
                } catch (Exception ex) {
                    Logger.getLogger(vistaProveedor.class.getName()).log(Level.SEVERE, null, ex);
                }
                
         }else{
         try {
             
                c=ContactoControl.BuscarContacto(txtIdContacto.getText());
                if(c == null){
                        c = new Contacto();
                        c.setProveedor(ControlProveedor.BuscarProveedor(nit.getText()));
                        c.setId(txtIdContacto.getText());
                        c.setNombre(txtNombreContacto.getText());
                        c.setApellido(txtApellidoContacto.getText());
                        c.setDireccion(txtDireccionContacto.getText());
                        c.setTelefono(txtTelefonoContacto.getText());
                        c.setCelular(txtCelullarContacto.getText());
                        ContactoControl.RegistrarContacto(c);
                         ListarContactos(listaproveedor.getSelectedItem().toString());
                        vistas.VaciarCampos(txtIdContacto, txtNombreContacto, txtApellidoContacto, txtDireccionContacto, txtTelefonoContacto, txtCelullarContacto);
                        RegistroContacto.setVisible(false);
                 }else
                      mensaje2.setText("Contacto Ya existe");
            } catch (SQLException ex) {
                Logger.getLogger(vistaProveedor.class.getName()).log(Level.SEVERE, null, ex);
            } catch (IOException ex) {
                Logger.getLogger(vistaProveedor.class.getName()).log(Level.SEVERE, null, ex);
            } catch (Exception ex) {
                Logger.getLogger(vistaProveedor.class.getName()).log(Level.SEVERE, null, ex);
            }
         }
        }else
           mensaje2.setText("Campo esta Vacio..");
        
    }//GEN-LAST:event_btnRegistroContactoActionPerformed

    private void btn_AgregarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_AgregarActionPerformed
        try {
            Contacto c = new Contacto();
            String  nitemp = listaproveedor.getSelectedItem().toString();
            c.setProveedor(ControlProveedor.BuscarProveedornombre(nitemp));
            nombre.setText(c.getProveedor().getNombre());
            nit.setText(c.getProveedor().getNit());
            btnRegistroContacto.setText("Registrar");
            limpiar.setVisible(true);
            LimpiarRegistroContrato();
            RegistroContacto.setLocationRelativeTo(this);
            RegistroContacto.setVisible(true);
        } catch (SQLException ex) {
            Logger.getLogger(vistaProveedor.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_btn_AgregarActionPerformed

    private void txtIdContactoFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtIdContactoFocusGained
      vistas.RetornaColor(txtIdContacto);
      vistas.VaciarCampos(mensaje2);
    }//GEN-LAST:event_txtIdContactoFocusGained

    private void txtNombreContactoFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtNombreContactoFocusGained
       vistas.RetornaColor(txtNombreContacto);
       vistas.VaciarCampos(mensaje2);
    }//GEN-LAST:event_txtNombreContactoFocusGained

    private void txtApellidoContactoFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtApellidoContactoFocusGained
       vistas.RetornaColor(txtApellidoContacto);
       vistas.VaciarCampos(mensaje2);
    }//GEN-LAST:event_txtApellidoContactoFocusGained

    private void limpiarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_limpiarActionPerformed
      
        vistas.VaciarCampos(txtIdContacto, txtNombreContacto, txtApellidoContacto, txtDireccionContacto, txtTelefonoContacto, txtCelullarContacto);
        
    }//GEN-LAST:event_limpiarActionPerformed

    private void txtTelefonoContactoKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtTelefonoContactoKeyReleased
       vistas.validarnumero(txtTelefonoContacto, mensaje2);
    }//GEN-LAST:event_txtTelefonoContactoKeyReleased

    private void txtCelullarContactoKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtCelullarContactoKeyReleased
        vistas.validarnumero(txtCelullarContacto, mensaje2);
        
    }//GEN-LAST:event_txtCelullarContactoKeyReleased

    private void jXTable1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jXTable1MouseClicked
       if(jXTable1.getRowCount()>0)
          btn_EditarContactos.setEnabled(true);
                  
            
    }//GEN-LAST:event_jXTable1MouseClicked

    private void btn_EditarContactosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_EditarContactosActionPerformed
         int x = jXTable1.getSelectedRow();
        if(x <0){
            mensaje.setText("Seleccione Primero el Contacto");
        }else{
            try {
                i = dtm.getValueAt(x, 0).toString();
                btnRegistroContacto.setText("Guardar");
                val=true;
                Contacto c ;
                c = ContactoControl.BuscarContacto(i);
                String  nitemp = listaproveedor.getSelectedItem().toString();
                txtIdContacto.setText(c.getId());
                txtNombreContacto.setText(c.getNombre());
                txtApellidoContacto.setText(c.getApellido());
                txtDireccionContacto.setText(c.getDireccion());
                txtTelefonoContacto.setText(c.getTelefono());
                txtCelullarContacto.setText(c.getCelular());
                c.setProveedor(ControlProveedor.BuscarProveedornombre(nitemp));
                nombre.setText(c.getProveedor().getNombre());
                nit.setText(c.getProveedor().getNit());
                limpiar.setVisible(false);
                RegistroContacto.setLocationRelativeTo(this);
                RegistroContacto.setVisible(true);
            } catch (SQLException ex) {
                Logger.getLogger(vistaProveedor.class.getName()).log(Level.SEVERE, null, ex);
            }
            
        }
        
    }//GEN-LAST:event_btn_EditarContactosActionPerformed

    private void txtEditarTelefonoKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtEditarTelefonoKeyReleased
     
        vistas.validarnumero(txtEditarTelefono, mensaje);
    }//GEN-LAST:event_txtEditarTelefonoKeyReleased

    private void txtIdContactoKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtIdContactoKeyReleased
       vistas.validarnumero(txtIdContacto, mensaje2);
    }//GEN-LAST:event_txtIdContactoKeyReleased

    private void btnsalirnuevocont1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnsalirnuevocont1ActionPerformed
this.dispose();   
// TODO add your handling code here:
    }//GEN-LAST:event_btnsalirnuevocont1ActionPerformed

    private void jXTable2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jXTable2MouseClicked
        // TODO add your handling code here:
    }//GEN-LAST:event_jXTable2MouseClicked

    private void btn_EditarContactos1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_EditarContactos1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_btn_EditarContactos1ActionPerformed

    private void btn_Agregar1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_Agregar1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_btn_Agregar1ActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
     

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new vistaProveedor().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JDialog RegistroContacto;
    private javax.swing.JButton btnRegistroContacto;
    private javax.swing.JButton btn_Agregar;
    private javax.swing.JButton btn_Agregar1;
    private javax.swing.JButton btn_EditarContactos;
    private javax.swing.JButton btn_EditarContactos1;
    private javax.swing.JButton btn_EditarProveedor;
    private javax.swing.JButton btn_LimpiarProve;
    private javax.swing.JButton btn_RegistrarProve;
    private javax.swing.JButton btn_salir;
    private javax.swing.JButton btnsalirnuevocont;
    private javax.swing.JButton btnsalirnuevocont1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel10;
    private javax.swing.JPanel jPanel11;
    private javax.swing.JPanel jPanel12;
    private javax.swing.JPanel jPanel13;
    private javax.swing.JPanel jPanel14;
    private javax.swing.JPanel jPanel15;
    private javax.swing.JPanel jPanel16;
    private javax.swing.JPanel jPanel17;
    private javax.swing.JPanel jPanel18;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JPanel jPanel9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTabbedPane jTabbedPane2;
    private org.jdesktop.swingx.JXTable jXTable1;
    private org.jdesktop.swingx.JXTable jXTable2;
    private javax.swing.JButton limpiar;
    private javax.swing.JComboBox listaproveedor;
    private javax.swing.JLabel mensaje;
    private javax.swing.JLabel mensaje2;
    private javax.swing.JLabel nit;
    private javax.swing.JLabel nombre;
    private javax.swing.JTextField txtApellidoContacto;
    private javax.swing.JTextField txtCelullarContacto;
    private javax.swing.JTextField txtDireccion;
    private javax.swing.JTextField txtDireccionContacto;
    private javax.swing.JTextField txtEdiartNit;
    private javax.swing.JTextField txtEditarDireccion;
    private javax.swing.JTextField txtEditarNombre;
    private javax.swing.JTextField txtEditarTelefono;
    private javax.swing.JTextField txtIdContacto;
    private javax.swing.JTextField txtNit;
    private javax.swing.JTextField txtNombre;
    private javax.swing.JTextField txtNombreContacto;
    private javax.swing.JTextField txtTelefono;
    private javax.swing.JTextField txtTelefonoContacto;
    // End of variables declaration//GEN-END:variables

public void listarProveedor(){
        try {
            ControlProveedor.listarProveedor();
             cbprov.removeAllElements();
            Iterator it=ControlProveedor.getProveedor().iterator();
            cbprov.addElement("Seleccione Proveedor");
            while(it.hasNext()){
              Proveedor pr=(Proveedor)it.next();
                cbprov.addElement(pr.getNombre());
            }
            listaproveedor.setModel(cbprov);
        } catch (SQLException ex) {
            Logger.getLogger(vistaProveedor.class.getName()).log(Level.SEVERE, null, ex);
        } catch (Exception ex) {
            Logger.getLogger(vistaProveedor.class.getName()).log(Level.SEVERE, null, ex);
        }
       
}
public void ListarContactos(String nombre){
        try {
                        
            Proveedor p = ControlProveedor.BuscarProveedornombre(nombre);
            dtm.setNumRows(0);
            ContactoControl.listarContacto(p.getNit());
                   Iterator it =  ContactoControl.getContacto().iterator();
                   while (it.hasNext()) {
                               Contacto cont= (Contacto) it.next();
                               String[] fila = {cont.getId(),cont.getNombre()+" "+cont.getApellido(), cont.getDireccion(), cont.getTelefono(), cont.getCelular()};
                                 dtm.addRow(fila);
              
                    }
        } catch (SQLException ex) {
            Logger.getLogger(vistaProveedor.class.getName()).log(Level.SEVERE, null, ex);
        }catch(NullPointerException npe){
            
        }catch (Exception ex) {
            Logger.getLogger(vistaProveedor.class.getName()).log(Level.SEVERE, null, ex);
        }
}
    private void listaProductos(String nombre) {
        try {
            Proveedor p1 = ControlProveedor.BuscarProveedornombre(nombre);
            dtm2.setNumRows(0);
            Proveedor p = ControlProveedor.BuscarProveedor(p1.getNit());
            ManejadorBaseDatos mbd = ManejadorBaseDatos.getInstancia();
            mbd.conectar();      
            ControlProducto.con = mbd.getConexion();
            ControlProducto.listarProducto1("SELECT *FROM productos WHERE codproveedor='"+p.getNit()+"'");
            Iterator it =  ControlProducto.getProducto().iterator();
                   while (it.hasNext()) {
                               Producto pro = (Producto) it.next();
                               int stm = (int) pro.getStockMin();
                               int can = (int) pro.getCantidad();
                               String[] fila = {pro.getCodigo(), pro.getNombre(),pro.getDescripcion(), can+""};
                                 dtm2.addRow(fila);
              
                    }
        } catch (SQLException ex) {
            Logger.getLogger(VistaCompra.class.getName()).log(Level.SEVERE, null, ex);
        } catch (Exception ex) {
            Logger.getLogger(VistaCompra.class.getName()).log(Level.SEVERE, null, ex);
        }
 }
    private void LimpiarRegistroContrato() {
       txtIdContacto.setText("");
       txtNombreContacto.setText("");
       txtApellidoContacto.setText("");
       txtDireccionContacto.setText("");
       txtTelefonoContacto.setText("");
       txtCelullarContacto.setText("");
    }
}
